package com.client.dbdao;

import com.data.dbdao.BaseDao;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 分类管理的数据层
 *
 * @author:HingLo
 * @create 2017-10-11 13:49
 **/
@Repository
@Transactional
public class MenuClientDao extends BaseDao {

    /**
     * .
     * 根据菜单类型返回分类信息
     *
     * @param type
     * @return
     */
    public List<?> findMenuClientDao(Integer type) {
        String hql = "select id,fid,name from Menu where type=? and fid=?";
        return super.findMassageDao(hql, type, String.valueOf(type));
    }

    /**
     * 二级菜单
     *
     * @param id
     * @return
     */
    public List<?> findMenuTwoClientDao(String id) {
        String hql = "select id,fid,name from Menu where fid=?";
        return super.findMassageDao(hql, id);
    }

    public List<?> findMenuSoftwareDao(String id, int start, int end) {
        String hql = "select a.id,a.name ,a.introduce,m.name as mname,a.size,a.version,(SELECT AVG(s.star) from Speaking as s where s.rid=a.id ) as num,a.state,a.type,(SELECT d.down from AppDownload as d where d.id=a.id) as down ,a.md5,a.packagename,a.content,a.vcontent,a.ctime  from App as a ,Menu as m where  m.id=a.menuid and a.id in (SELECT rid from AppMenu WHERE mid=?) limit ?,?";
        return super.findMysqlMethodDao(hql, id, start, end);
    }
}
